/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.srcptit.javatrainning.hieptq.btvn1;

/**
 *
 * @author Hiep
 */
public class Bai8 {
    static boolean nguyento(int n){
		if(n==0||n==1)return false;
		for(int i=2;i<Math.sqrt(n);i++)
			if(n%i==0) return false;
		return true;
		}
   static boolean chusongto(int n){
	   while(n>0){
		   int t;
		   t=n%10;
		   if(!nguyento(t)){
			   return false;
		   }
		   n=n/10;
	   }
		   return true;
	   }
   static boolean daykogiam(int n){
	   while(n>0){
		   if((n%10)>((n/10)%10)) return true;
		   n=n/10;
	   }
		   return false;
	   }
   
  
   public static void main(String[] args){
	   for(int i=1000000;i<=9999999;i++)
		   if(nguyento(i)&chusongto(i)&daykogiam(i))
			   System.out.println(" "+i);
   }
}



